﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BusinessApplication1.ServiceReference;
using System.Collections.ObjectModel;

namespace BusinessApplication1.Views.Task
{
    public partial class AddNewTask : ChildWindow
    {

        private ObservableCollection<Project> _ProjectsList;

        public ObservableCollection<Project> ProjectsList
        {
            get { return _ProjectsList; }
            set { _ProjectsList = value; }
        }

        public AddNewTask()
        {
            InitializeComponent();

            ProjectsList = new ObservableCollection<Project>();

            //Project myProj = new Project();
            //myProj.Name = "smthn";

            //_ProjectsList.Add(myProj);

            ProjectDatabaseInteractionClient svc = new ProjectDatabaseInteractionClient();

            svc.GetProjectListCompleted += (_s, _e) =>
            {
                foreach(Project p in _e.Result)
                    _ProjectsList.Add(p);

                _ProjectsList.Add(new Project());

            };
            svc.GetProjectListAsync();


        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

